using System;
using System.Collections;
using Widgetsphere.Generator.Common.Util;

namespace Widgetsphere.Generator.Common.GeneratorFramework
{
	public interface IProjectItemGenerator
	{
		void Initialize(IModelObject model);
		void Generate();
		int FileCount { get; }
		event ProjectItemGeneratedEventHandler ProjectItemGenerated;
		event ProjectItemGenerationCompleteEventHandler GenerationComplete;
	}

	public delegate void ProjectItemGeneratedEventHandler(object sender, ProjectItemGeneratedEventArgs e);
	public delegate void ProjectItemGenerationCompleteEventHandler(object sender, ProjectItemGenerationCompleteEventArgs e);

	public enum ProjectItemType
	{
		Folder = 0,
		File = 1
	}

	public enum ProjectItemContentType
	{
		String = 0,
		File = 1
	}

	public class ProjectItemGeneratedEventArgs : System.EventArgs
	{
		#region Class Members

		private string _projectItemName = string.Empty;
		private Hashtable _properties = new Hashtable();
		private string _projectItemContent = string.Empty;
		private string _projectName = string.Empty;
		private string _parentItemName = string.Empty;
		private ProjectItemType _parentItemType = ProjectItemType.File;
		private ProjectItemContentType _contentType = ProjectItemContentType.String;
		private bool _overwrite = true;
		private EnvDTEHelper.FileStateConstants _fileState = EnvDTEHelper.FileStateConstants.Success;
		private string _fullName = "";
		private IProjectItemGenerator _baseGenerator = null;

		#endregion

		#region Constructors

		public ProjectItemGeneratedEventArgs(string projectItemName, string projectItemContent, string projectName, IProjectItemGenerator baseGenerator, bool overwrite)
		{
			_baseGenerator = baseGenerator;
			_projectItemName = projectItemName;
			_projectItemContent = projectItemContent;
			_projectName = projectName;
			_overwrite = overwrite;
		}

		public ProjectItemGeneratedEventArgs(string projectItemName, string projectItemContent, string projectName, string parentItemName, IProjectItemGenerator baseGenerator, bool overwrite)
		{
			_baseGenerator = baseGenerator;
			_projectItemName = projectItemName;
			_projectItemContent = projectItemContent;
			_projectName = projectName;
			_parentItemName = parentItemName;
			_overwrite = overwrite;
		}

		public ProjectItemGeneratedEventArgs(string projectItemName, string projectItemContent, string projectName, string parentItemName, ProjectItemType parentItemType, IProjectItemGenerator baseGenerator, bool overwrite)
		{
			_baseGenerator = baseGenerator;
			_projectItemName = projectItemName;
			_projectItemContent = projectItemContent;
			_projectName = projectName;
			_parentItemName = parentItemName;
			_parentItemType = parentItemType;
			_overwrite = overwrite;
		}

		#endregion

		#region Property Implementations

		public EnvDTEHelper.FileStateConstants FileState
		{
			get { return _fileState; }
			set { _fileState = value; }
		}

		public string FullName
		{
			get { return _fullName; }
			set { _fullName = value; }
		}

		public IProjectItemGenerator BaseGenerator
		{
			get { return _baseGenerator; }
		}

		public ProjectItemType ParentItemType
		{
			get { return _parentItemType; }
		}

		public ProjectItemContentType ContentType
		{
			get { return _contentType; }
			set { _contentType = value; }
		}

		public string ParentItemName
		{
			get { return _parentItemName; }
		}

		public string ProjectName
		{
			get { return _projectName; }
		}

		public string ProjectItemName
		{
			get { return _projectItemName; }
		}

		public string ProjectItemContent
		{
			get { return _projectItemContent; }
		}

		public Hashtable Properties
		{
			get { return _properties; }
			set { _properties = value; }
		}

		public bool Overwrite
		{
			get { return _overwrite; }
		}

		#endregion

	}

	public class ProjectItemGenerationCompleteEventArgs : System.EventArgs
	{
		private IProjectItemGenerator _projectItemGenerator;

		public ProjectItemGenerationCompleteEventArgs(IProjectItemGenerator projectItemGenerator)
		{
			_projectItemGenerator = projectItemGenerator;
		}

		public IProjectItemGenerator ProjectItemGenerator
		{
			get { return _projectItemGenerator; }
		}

	}

}
